<?php
################################################################################
#
# ID:     $Id: $
# Author: John Griffin
# Date:   April 23, 2009
#
################################################################################
define ('DATABASE_CONNECT_STRING', 'mysql:host=localhost;dbname=breakdown');
define ('DATABASE_USER', 'john');
define ('DATABASE_PASSWORD', 'john');

global $db;
global $stmt;
global $max_depth;

function level ($depth, $path, $sample, $max_depth, $db, $stmt) {
    if ($depth < $max_depth) {
        for ($i = 0; $i < $sample; $i++) {
            $subject = $i;
echo "(\$subject, \$path, 'Body for \$subject') == ($subject, $path, 'Body for $subject')\n";
            $stmt->execute (array ($subject, $path, "Body for $subject"));
            $insert_id = $db->lastInsertId ();
            level ($depth + 1, $path.'.'.$insert_id, rand (0, 5), $max_depth, $db, $stmt);
        }
    }
}
$db = new PDO (DATABASE_CONNECT_STRING, DATABASE_USER, DATABASE_PASSWORD);
$stmt = $db->prepare ("insert into bd_task (subject, path, body) values (?, ?, ?)");
$max_depth = 5;
level (0, '', 10, $max_depth, $db, $stmt);
?>
